import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [{
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import( /* webpackChunkName: "about" */ '../views/About.vue')
  },
  {
    path: '/login',
    name: 'Homes',
    component: () => import("../components/login.vue"),
    meta: {
      title: "登录"
    }
  },
   {
     path: '/ce',
     component: () => import("../components/ce.vue"),
     meta: {
       title: "调查问卷新用户注册"
     }
   },
    {
      path: '/gai',
      component: () => import("../components/gai.vue"),
      meta: {
        title: "编辑个人信息"
      }
    },
    {
      path: '/like',
      component: () => import("../components/cang.vue"),
      meta: {
        title: "我的收藏"
      }
    },
  {
    path: '/index',
    name: 'Hom',
    component: () => import("../components/index.vue"),
    meta: {title: "主页"},
    children: [
      {path: 'chi/:id',component:()=>import("../components/chi.vue") ,meta: {title: "主页"}},
      {path: 'answer',component:()=>import("../components/answer.vue") ,meta: {title: "主页"}},
      {path: 'daan',component:()=>import("../components/daan.vue") ,meta: {title: "主页"}},
      {path: 'a',component:()=>import("../components/aaaa.vue") ,meta: {title: "主页"}}


      
  ]
  },
]


const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})


router.beforeEach((to, from, next) => {
  document.title = to.meta.title
  next()
})


export default router